package com.java8;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

/**
 * @author Administrator
 */
public class MethodRefTest {

    public static void main(String args[]){
        List names = new ArrayList();

        names.add("Google");
        names.add("Runoob");
        names.add("Taobao");
        names.add("Baidu");
        names.add("Sina");

        names.forEach(System.out::println);
    }

    //Supplier是jdk1.8的接口，这里和lamda一起使用了
    public static MethodRefTest create(final Supplier<MethodRefTest> supplier) {
        return supplier.get();
    }

    public static void collide(final MethodRefTest car) {
        System.out.println("Collided " + car.toString());
    }

    public void follow(final MethodRefTest another) {
        System.out.println("Following the " + another.toString());
    }

    public void repair() {
        System.out.println("Repaired " + this.toString());
    }
}